package com.ruoyi.project.tool.swagger.UserController;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SysOrderEvaluate;
import com.ruoyi.project.system.service.ISysOrderEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单评价Controller
 *
 * @author jjp
 * @date 2020-04-29
 */
@RestController
@Api("订单评价")
@RequestMapping("/mobileUser/evaluate")
public class UserOrderEvaluateController extends BaseController {
    @Autowired
    private ISysOrderEvaluateService sysOrderEvaluateService;

    /**
     * 查询订单评价列表
     */
    @ApiOperation("查询订单评价列表")
    @GetMapping("/list")
    public TableDataInfo list(SysOrderEvaluate sysOrderEvaluate) {
        sysOrderEvaluate.setMobileUserId(SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId());
        startPage();
        List<SysOrderEvaluate> list = sysOrderEvaluateService.selectSysOrderEvaluateList(sysOrderEvaluate);
        return getDataTable(list);
    }



    /**
     * 新增订单评价
     */
    @ApiOperation("新增订单评价")
    @Log(title = "订单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysOrderEvaluate sysOrderEvaluate) {
        sysOrderEvaluate.setMobileUserId(SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId());
        return toAjax(sysOrderEvaluateService.insertSysOrderEvaluate(sysOrderEvaluate));
    }


}
